**************************************************************************
* Stata replication code for
* Ordering Effects in Stereotype Scales
* L.J Zigerell
* November 2025
**************************************************************************

**************************************************************************
* Open the ANES 2022 Pilot Study dataset
* Dataset available at: https://electionstudies.org/data-center/2022-pilot-study/
* December 14, 2022 version
**************************************************************************

clear all
use "anes_pilot_2022_stata_20221214.dta"

set cformat %9.2f // Set formatting to two decimal places

**************************************************************************
* The code below indicates that the order of the hardworking stereotype
* items was the same as the order of the intelligence stereotype items.
* Therefore, I will code one set of variables for this ordering.
**************************************************************************

desc    ord_swhwork ord_swhintel 
tab     ord_swhwork ord_swhintel, mi

desc    ord_sblwork ord_sblintel
tab     ord_sblwork ord_sblintel, mi

desc    ord_slawork ord_slaintel
tab     ord_slawork ord_slaintel, mi

desc    ord_saswork ord_sasintel
tab     ord_saswork ord_sasintel, mi

**************************************************************************
* The ORD?1 variables below are coded 1 if the indicated group was first
* in the list of groups and coded 0 otherwise. So, for example, 
* ORDW1 is coded 1 for participants who received the stereotype items about
* Whites first and coded 0 for all other participants
**************************************************************************

gen     ORDW1 = 1 if ord_swhwork == 1
gen     ORDB1 = 1 if ord_sblwork == 1
gen     ORDH1 = 1 if ord_slawork == 1
gen     ORDA1 = 1 if ord_saswork == 1

replace ORDW1 = 0 if ord_swhwork >= 2 & ord_swhwork <= 4
replace ORDB1 = 0 if ord_sblwork >= 2 & ord_sblwork <= 4
replace ORDH1 = 0 if ord_slawork >= 2 & ord_slawork <= 4
replace ORDA1 = 0 if ord_saswork >= 2 & ord_saswork <= 4

tab1    ORDW1 ORDB1 ORDH1 ORDA1, mi

* Coding check below for intelligent stereotype items

gen     ORDW1_CHECK = 1 if ord_swhintel == 1
gen     ORDB1_CHECK = 1 if ord_sblintel == 1
gen     ORDH1_CHECK = 1 if ord_slaintel == 1
gen     ORDA1_CHECK = 1 if ord_sasintel == 1

replace ORDW1_CHECK = 0 if ord_swhintel >= 2 & ord_swhintel <= 4
replace ORDB1_CHECK = 0 if ord_sblintel >= 2 & ord_sblintel <= 4
replace ORDH1_CHECK = 0 if ord_slaintel >= 2 & ord_slaintel <= 4
replace ORDA1_CHECK = 0 if ord_sasintel >= 2 & ord_sasintel <= 4

tab     ORDW1 ORDW1_CHECK, mi
tab     ORDB1 ORDB1_CHECK, mi
tab     ORDH1 ORDH1_CHECK, mi
tab     ORDA1 ORDA1_CHECK, mi

**************************************************************************
* Coding of the ordering variables
* Example: ORDWA is coded 1 if Whites were asked about first and
*          coded 0 if Asian-Americans were asked about first
**************************************************************************

gen     ORDWA = 1 if ORDW1 == 1
replace ORDWA = 0 if ORDA1 == 1

gen     ORDAW = 0 if ORDW1 == 1
replace ORDAW = 1 if ORDA1 == 1

gen     ORDHA = 1 if ORDH1 == 1
replace ORDHA = 0 if ORDA1 == 1

gen     ORDAH = 0 if ORDH1 == 1
replace ORDAH = 1 if ORDA1 == 1

gen     ORDBA = 1 if ORDB1 == 1
replace ORDBA = 0 if ORDA1 == 1

gen     ORDAB = 0 if ORDB1 == 1
replace ORDAB = 1 if ORDA1 == 1

gen     ORDWH = 1 if ORDW1 == 1
replace ORDWH = 0 if ORDH1 == 1

gen     ORDHW = 0 if ORDW1 == 1
replace ORDHW = 1 if ORDH1 == 1

gen     ORDBH = 1 if ORDB1 == 1
replace ORDBH = 0 if ORDH1 == 1

gen     ORDHB = 0 if ORDB1 == 1
replace ORDHB = 1 if ORDH1 == 1

gen     ORDBW = 1 if ORDB1 == 1
replace ORDBW = 0 if ORDW1 == 1

gen     ORDWB = 0 if ORDB1 == 1
replace ORDWB = 1 if ORDW1 == 1

**************************************************************************
* [Hardworking] Coding of the hardworking stereotype items
**************************************************************************

tab1    swhwork sblwork slawork saswork
tab1    swhwork sblwork slawork saswork, nol mi

gen     WORKW = 8 - swhwork if swhwork >= 1 & swhwork <= 7
gen     WORKB = 8 - sblwork if sblwork >= 1 & sblwork <= 7
gen     WORKH = 8 - slawork if slawork >= 1 & slawork <= 7
gen     WORKA = 8 - saswork if saswork >= 1 & saswork <= 7

* Statistics including missing as its own category [for Figure A1]:

recode  WORKW WORKB WORKH WORKA (. = 99)
tab1    WORKW WORKB WORKH WORKA, mi
mean    WORKW WORKB WORKH WORKA
prop    WORKW WORKB WORKH WORKA, level(83.4)

* Return missing to a missing code:

recode  WORKW WORKB WORKH WORKA (99 = .)
tab1    WORKW WORKB WORKH WORKA, mi

**************************************************************************
* [Hardworking] Coding of the comparison variables
**************************************************************************

mean    WORKW WORKB WORKH WORKA
prop    WORKW WORKB WORKH WORKA, level(83.4)

* Asian-Americans + Whites

gen     WORKAW = WORKA - WORKW
tab     WORKAW
recode  WORKAW (-6/-1 = 1 "WORK W > A") (0 = 2 "WORK A = W") (1/6 = 3 "WORK A > W") (. = 0 "Missing"), gen(WORKAW3)
tab     WORKAW3, mi

recode  WORKAW ( 1/ 6 = 1 "WORK A > W") (else = 0 "Else"), gen(WORKAW2)
recode  WORKAW (-6/-1 = 1 "WORK W > A") (else = 0 "Else"), gen(WORKWA2)
tab     WORKAW2, mi
tab     WORKWA2, mi

* Asian-Americans + Hispanics

gen     WORKAH = WORKA - WORKH
tab     WORKAH
recode  WORKAH (-6/-1 = 1 "WORK H > A") (0 = 2 "WORK A = H") (1/6 = 3 "WORK A > H") (. = 0 "Missing"), gen(WORKAH3)
tab     WORKAH3, mi

recode  WORKAH ( 1/ 6 = 1 "WORK A > H") (else = 0 "Else"), gen(WORKAH2)
recode  WORKAH (-6/-1 = 1 "WORK H > A") (else = 0 "Else"), gen(WORKHA2)
tab     WORKAH2, mi
tab     WORKHA2, mi

* Asian-Americans + Blacks

gen     WORKAB = WORKA - WORKB
tab     WORKAB
recode  WORKAB (-6/-1 = 1 "WORK B > A") (0 = 2 "WORK A = B") (1/6 = 3 "WORK A > B") (. = 0 "Missing"), gen(WORKAB3)
tab     WORKAB3, mi

recode  WORKAB ( 1/ 6 = 1 "WORK A > B") (else = 0 "Else"), gen(WORKAB2)
recode  WORKAB (-6/-1 = 1 "WORK B > A") (else = 0 "Else"), gen(WORKBA2)
tab     WORKAB2, mi
tab     WORKBA2, mi

* Hispanics + Whites

gen     WORKHW = WORKH - WORKW
tab     WORKHW
recode  WORKHW (-6/-1 = 1 "WORK W > H") (0 = 2 "WORK H = W") (1/6 = 3 "WORK H > W") (. = 0 "Missing"), gen(WORKHW3)
tab     WORKHW3, mi

recode  WORKHW ( 1/ 6 = 1 "WORK H > W") (else = 0 "Else"), gen(WORKHW2)
recode  WORKHW (-6/-1 = 1 "WORK W > H") (else = 0 "Else"), gen(WORKWH2)
tab     WORKHW2, mi
tab     WORKWH2, mi

* Hispanics + Blacks

gen     WORKHB = WORKH - WORKB
tab     WORKHB
recode  WORKHB (-6/-1 = 1 "WORK B > H") (0 = 2 "WORK H = B") (1/6 = 3 "WORK H > B") (. = 0 "Missing"), gen(WORKHB3)
tab     WORKHB3, mi

recode  WORKHB ( 1/ 6 = 1 "WORK H > B") (else = 0 "Else"), gen(WORKHB2)
recode  WORKHB (-6/-1 = 1 "WORK B > H") (else = 0 "Else"), gen(WORKBH2)
tab     WORKHB2, mi
tab     WORKBH2, mi

* Whites + Blacks

gen     WORKWB = WORKW - WORKB
tab     WORKWB
recode  WORKWB (-6/-1 = 1 "WORK B > W") (0 = 2 "WORK W = B") (1/6 = 3 "WORK W > B") (. = 0 "Missing"), gen(WORKWB3)
tab     WORKWB3, mi

recode  WORKWB ( 1/ 6 = 1 "WORK W > B") (else = 0 "Else"), gen(WORKWB2)
recode  WORKWB (-6/-1 = 1 "WORK B > W") (else = 0 "Else"), gen(WORKBW2)
tab     WORKWB2, mi
tab     WORKBW2, mi

**************************************************************************
* [Hardworking] Unweighted analysis
**************************************************************************

* This part is to get 83.4% confidence intervals [column 1 of appendix Table A1]

prop    WORKAW3 if ORDA1 == 1, level(83.4)
prop    WORKAW3 if ORDW1 == 1, level(83.4)

prop    WORKAH3 if ORDA1 == 1, level(83.4)
prop    WORKAH3 if ORDH1 == 1, level(83.4)

prop    WORKAB3 if ORDA1 == 1, level(83.4)
prop    WORKAB3 if ORDB1 == 1, level(83.4)

prop    WORKHW3 if ORDH1 == 1, level(83.4)
prop    WORKHW3 if ORDW1 == 1, level(83.4)

prop    WORKHB3 if ORDH1 == 1, level(83.4)
prop    WORKHB3 if ORDB1 == 1, level(83.4)

prop    WORKWB3 if ORDW1 == 1, level(83.4)
prop    WORKWB3 if ORDB1 == 1, level(83.4)

* This part is to get p-values for the comparisons [column 1 of appendix Table A1]

prtest  WORKAW2 if ORDA1 == 1 | ORDW1 == 1, by(ORDW1)
prtest  WORKWA2 if ORDA1 == 1 | ORDW1 == 1, by(ORDA1)

prtest  WORKAH2 if ORDA1 == 1 | ORDH1 == 1, by(ORDH1)
prtest  WORKHA2 if ORDA1 == 1 | ORDH1 == 1, by(ORDA1)

prtest  WORKAB2 if ORDA1 == 1 | ORDB1 == 1, by(ORDB1)
prtest  WORKBA2 if ORDA1 == 1 | ORDB1 == 1, by(ORDA1)

prtest  WORKHW2 if ORDH1 == 1 | ORDW1 == 1, by(ORDW1)
prtest  WORKWH2 if ORDH1 == 1 | ORDW1 == 1, by(ORDH1)

prtest  WORKHB2 if ORDH1 == 1 | ORDB1 == 1, by(ORDB1)
prtest  WORKBH2 if ORDH1 == 1 | ORDB1 == 1, by(ORDH1)

prtest  WORKWB2 if ORDW1 == 1 | ORDB1 == 1, by(ORDB1)
prtest  WORKBW2 if ORDW1 == 1 | ORDB1 == 1, by(ORDW1)

**************************************************************************
* [Hardworking] Weighted analysis
* For each set below, 
* the first two lines are to get 83.4% confidence intervals, 
* and the third and fourth lines are to get p-values for the comparison.
* The fourth line also has 95% confidence intervals for the difference.
**************************************************************************

svyset [pw = weight]

svy, subpop(if ORDA1 == 1): prop   WORKAW2, level(83.4)
svy, subpop(if ORDW1 == 1): prop   WORKAW2, level(83.4)
svy, subpop(if ORDWA != .): prop   WORKAW2, over(ORDWA) level(83.4) coeflegend
lincom _b[1.WORKAW2@0bn.ORDWA] - _b[1.WORKAW2@1.ORDWA]

svy, subpop(if ORDW1 == 1): prop   WORKWA2, level(83.4)
svy, subpop(if ORDA1 == 1): prop   WORKWA2, level(83.4)
svy, subpop(if ORDAW != .): prop   WORKWA2, over(ORDAW) level(83.4) coeflegend
lincom _b[1.WORKWA2@0bn.ORDAW] - _b[1.WORKWA2@1.ORDAW]

svy, subpop(if ORDA1 == 1): prop   WORKAH2, level(83.4)
svy, subpop(if ORDH1 == 1): prop   WORKAH2, level(83.4)
svy, subpop(if ORDHA != .): prop   WORKAH2, over(ORDHA) level(83.4) coeflegend
lincom _b[1.WORKAH2@0bn.ORDHA] - _b[1.WORKAH2@1.ORDHA]

svy, subpop(if ORDH1 == 1): prop   WORKHA2, level(83.4)
svy, subpop(if ORDA1 == 1): prop   WORKHA2, level(83.4)
svy, subpop(if ORDAH != .): prop   WORKHA2, over(ORDAH) level(83.4) coeflegend
lincom _b[1.WORKHA2@0bn.ORDAH] - _b[1.WORKHA2@1.ORDAH]

svy, subpop(if ORDA1 == 1): prop   WORKAB2, level(83.4)
svy, subpop(if ORDB1 == 1): prop   WORKAB2, level(83.4)
svy, subpop(if ORDBA != .): prop   WORKAB2, over(ORDBA) level(83.4) coeflegend
lincom _b[1.WORKAB2@0bn.ORDBA] - _b[1.WORKAB2@1.ORDBA] 

svy, subpop(if ORDB1 == 1): prop   WORKBA2, level(83.4)
svy, subpop(if ORDA1 == 1): prop   WORKBA2, level(83.4)
svy, subpop(if ORDAB != .): prop   WORKBA2, over(ORDAB) level(83.4) coeflegend
lincom _b[1.WORKBA2@0bn.ORDAB] - _b[1.WORKBA2@1.ORDAB] 

svy, subpop(if ORDH1 == 1): prop   WORKHW2, level(83.4)
svy, subpop(if ORDW1 == 1): prop   WORKHW2, level(83.4)
svy, subpop(if ORDWH != .): prop   WORKHW2, over(ORDWH) level(83.4) coeflegend
lincom _b[1.WORKHW2@0bn.ORDWH] - _b[1.WORKHW2@1.ORDWH] 

svy, subpop(if ORDW1 == 1): prop   WORKWH2, level(83.4)
svy, subpop(if ORDH1 == 1): prop   WORKWH2, level(83.4)
svy, subpop(if ORDHW != .): prop   WORKWH2, over(ORDHW) level(83.4) coeflegend
lincom _b[1.WORKWH2@0bn.ORDHW] - _b[1.WORKWH2@1.ORDHW]

svy, subpop(if ORDH1 == 1): prop   WORKHB2, level(83.4)
svy, subpop(if ORDB1 == 1): prop   WORKHB2, level(83.4)
svy, subpop(if ORDBH != .): prop   WORKHB2, over(ORDBH) level(83.4) coeflegend
lincom _b[1.WORKHB2@0bn.ORDBH] - _b[1.WORKHB2@1.ORDBH]

svy, subpop(if ORDB1 == 1): prop   WORKBH2, level(83.4)
svy, subpop(if ORDH1 == 1): prop   WORKBH2, level(83.4)
svy, subpop(if ORDHB != .): prop   WORKBH2, over(ORDHB) level(83.4) coeflegend
lincom _b[1.WORKBH2@0bn.ORDHB] - _b[1.WORKBH2@1.ORDHB]

svy, subpop(if ORDW1 == 1): prop   WORKWB2, level(83.4)
svy, subpop(if ORDB1 == 1): prop   WORKWB2, level(83.4)
svy, subpop(if ORDBW != .): prop   WORKWB2, over(ORDBW) level(83.4) coeflegend
lincom _b[1.WORKWB2@0bn.ORDBW] - _b[1.WORKWB2@1.ORDBW]

svy, subpop(if ORDB1 == 1): prop   WORKBW2, level(83.4)
svy, subpop(if ORDW1 == 1): prop   WORKBW2, level(83.4)
svy, subpop(if ORDWB != .): prop   WORKBW2, over(ORDWB) level(83.4) coeflegend
lincom _b[1.WORKBW2@0bn.ORDWB] - _b[1.WORKBW2@1.ORDWB]

**************************************************************************
* [Intelligent] Coding of the intelligence stereotype items
**************************************************************************

tab1    swhintel sblintel slaintel sasintel
tab1    swhintel sblintel slaintel sasintel, nol mi

gen     INTELW = 8 - swhintel if swhintel >= 1 & swhintel <= 7
gen     INTELB = 8 - sblintel if sblintel >= 1 & sblintel <= 7
gen     INTELH = 8 - slaintel if slaintel >= 1 & slaintel <= 7
gen     INTELA = 8 - sasintel if sasintel >= 1 & sasintel <= 7

* Statistics including missing as its own category [for Figure A1]:

recode  INTELW INTELB INTELH INTELA (. = 99)
tab1    INTELW INTELB INTELH INTELA, mi
mean    INTELW INTELB INTELH INTELA
prop    INTELW INTELB INTELH INTELA, level(83.4)

* Return missing to a missing code:

recode  INTELW INTELB INTELH INTELA (99 = .)
tab1    INTELW INTELB INTELH INTELA, mi

**************************************************************************
* [Intelligent] Coding of the comparison variables
**************************************************************************

mean    INTELW INTELB INTELH INTELA
prop    INTELW INTELB INTELH INTELA, level(83.4)

recode  INTELW INTELB INTELH INTELA (99 = .)

* Asian-Americans + Whites

gen     INTELAW = INTELA - INTELW
tab     INTELAW
recode  INTELAW (-6/-1 = 1 "INTL W > A") (0 = 2 "INTL A = W") (1/6 = 3 "INTL A > W") (. = 0 "Missing"), gen(INTELAW3)
tab     INTELAW3, mi 

recode  INTELAW ( 1/ 6 = 1 "INTEL A > W") (else = 0 "Else"), gen(INTELAW2)
recode  INTELAW (-6/-1 = 1 "INTEL W > A") (else = 0 "Else"), gen(INTELWA2)
tab     INTELAW2, mi
tab     INTELWA2, mi

* Asian-Americans + Hispanics

gen     INTELAH = INTELA - INTELH
tab     INTELAH
recode  INTELAH (-6/-1 = 1 "INTL H > A") (0 = 2 "INTL A = H") (1/6 = 3 "INTL A > H") (. = 0 "Missing"), gen(INTELAH3)
tab     INTELAH3, mi  

recode  INTELAH ( 1/ 6 = 1 "INTEL A > H") (else = 0 "Else"), gen(INTELAH2)
recode  INTELAH (-6/-1 = 1 "INTEL H > A") (else = 0 "Else"), gen(INTELHA2)
tab     INTELAH2, mi
tab     INTELHA2, mi

* Asian-Americans + Blacks

gen     INTELAB = INTELA - INTELB
tab     INTELAB
recode  INTELAB (-6/-1 = 1 "INTL B > A") (0 = 2 "INTL A = B") (1/6 = 3 "INTL A > B") (. = 0 "Missing"), gen(INTELAB3)
tab     INTELAB3, mi  

recode  INTELAB ( 1/ 6 = 1 "INTEL A > B") (else = 0 "Else"), gen(INTELAB2)
recode  INTELAB (-6/-1 = 1 "INTEL B > A") (else = 0 "Else"), gen(INTELBA2)
tab     INTELAB2, mi
tab     INTELBA2, mi

* Hispanics + Whites

gen     INTELHW = INTELH - INTELW
tab     INTELHW
recode  INTELHW (-6/-1 = 1 "INTL W > H") (0 = 2 "INTL H = W") (1/6 = 3 "INTL H > W") (. = 0 "Missing"), gen(INTELHW3)
tab     INTELHW3, mi 

recode  INTELHW ( 1/ 6 = 1 "INTEL H > W") (else = 0 "Else"), gen(INTELHW2)
recode  INTELHW (-6/-1 = 1 "INTEL W > H") (else = 0 "Else"), gen(INTELWH2)
tab     INTELHW2, mi
tab     INTELWH2, mi

* Hispanics + Blacks

gen     INTELHB = INTELH - INTELB
tab     INTELHB
recode  INTELHB (-6/-1 = 1 "INTL B > H") (0 = 2 "INTL H = B") (1/6 = 3 "INTL H > B") (. = 0 "Missing"), gen(INTELHB3)
tab     INTELHB3, mi 

recode  INTELHB ( 1/ 6 = 1 "INTEL H > B") (else = 0 "Else"), gen(INTELHB2)
recode  INTELHB (-6/-1 = 1 "INTEL B > H") (else = 0 "Else"), gen(INTELBH2)
tab     INTELHB2, mi
tab     INTELBH2, mi

* Whites + Blacks

gen     INTELWB = INTELW - INTELB
tab     INTELWB
recode  INTELWB (-6/-1 = 1 "INTL B > W") (0 = 2 "INTL W = B") (1/6 = 3 "INTL W > B") (. = 0 "Missing"), gen(INTELWB3)
tab     INTELWB3, mi 

recode  INTELWB ( 1/ 6 = 1 "INTEL W > B") (else = 0 "Else"), gen(INTELWB2)
recode  INTELWB (-6/-1 = 1 "INTEL B > W") (else = 0 "Else"), gen(INTELBW2)
tab     INTELWB2, mi
tab     INTELBW2, mi

**************************************************************************
* [Intelligent] Unweighted analysis
**************************************************************************

* This part is to get 83.4% confidence intervals [column 3 of appendix Table A1]

prop    INTELAW3 if ORDA1 == 1, level(83.4)
prop    INTELAW3 if ORDW1 == 1, level(83.4)

prop    INTELAH3 if ORDA1 == 1, level(83.4)
prop    INTELAH3 if ORDH1 == 1, level(83.4)

prop    INTELAB3 if ORDA1 == 1, level(83.4)
prop    INTELAB3 if ORDB1 == 1, level(83.4)

prop    INTELHW3 if ORDH1 == 1, level(83.4)
prop    INTELHW3 if ORDW1 == 1, level(83.4)

prop    INTELHB3 if ORDH1 == 1, level(83.4)
prop    INTELHB3 if ORDB1 == 1, level(83.4)

prop    INTELWB3 if ORDW1 == 1, level(83.4)
prop    INTELWB3 if ORDB1 == 1, level(83.4)

* This part is to get p-values for the comparisons [column 3 of appendix Table A1]

prtest  INTELAW2 if ORDA1 == 1 | ORDW1 == 1, by(ORDW1)
prtest  INTELWA2 if ORDA1 == 1 | ORDW1 == 1, by(ORDA1)

prtest  INTELAH2 if ORDA1 == 1 | ORDH1 == 1, by(ORDH1)
prtest  INTELHA2 if ORDA1 == 1 | ORDH1 == 1, by(ORDA1)

prtest  INTELAB2 if ORDA1 == 1 | ORDB1 == 1, by(ORDB1)
prtest  INTELBA2 if ORDA1 == 1 | ORDB1 == 1, by(ORDA1)

prtest  INTELHW2 if ORDH1 == 1 | ORDW1 == 1, by(ORDW1)
prtest  INTELWH2 if ORDH1 == 1 | ORDW1 == 1, by(ORDH1)

prtest  INTELHB2 if ORDH1 == 1 | ORDB1 == 1, by(ORDB1)
prtest  INTELBH2 if ORDH1 == 1 | ORDB1 == 1, by(ORDH1)

prtest  INTELWB2 if ORDW1 == 1 | ORDB1 == 1, by(ORDB1)
prtest  INTELBW2 if ORDW1 == 1 | ORDB1 == 1, by(ORDW1)

**************************************************************************
* [Intelligent] Weighted analysis
* For each pair below, 
* the first two lines are to get 83.4% confidence intervals, 
* and the third and fourth lines are to get p-values for the comparison.
* The fourth line also has 95% confidence intervals for the difference.
**************************************************************************

svyset [pw = weight]

svy, subpop(if ORDA1 == 1): prop   INTELAW2, level(83.4)
svy, subpop(if ORDW1 == 1): prop   INTELAW2, level(83.4)
svy, subpop(if ORDWA != .): prop   INTELAW2, over(ORDWA) level(83.4) coeflegend
lincom _b[1.INTELAW2@0bn.ORDWA] - _b[1.INTELAW2@1.ORDWA]

svy, subpop(if ORDW1 == 1): prop   INTELWA2, level(83.4)
svy, subpop(if ORDA1 == 1): prop   INTELWA2, level(83.4)
svy, subpop(if ORDAW != .): prop   INTELWA2, over(ORDAW) level(83.4) coeflegend
lincom _b[1.INTELWA2@0bn.ORDAW] - _b[1.INTELWA2@1.ORDAW]

svy, subpop(if ORDA1 == 1): prop   INTELAH2, level(83.4)
svy, subpop(if ORDH1 == 1): prop   INTELAH2, level(83.4)
svy, subpop(if ORDHA != .): prop   INTELAH2, over(ORDHA) level(83.4) coeflegend
lincom _b[1.INTELAH2@0bn.ORDHA] - _b[1.INTELAH2@1.ORDHA]

svy, subpop(if ORDH1 == 1): prop   INTELHA2, level(83.4)
svy, subpop(if ORDA1 == 1): prop   INTELHA2, level(83.4)
svy, subpop(if ORDAH != .): prop   INTELHA2, over(ORDAH) level(83.4) coeflegend
lincom _b[1.INTELHA2@0bn.ORDAH] - _b[1.INTELHA2@1.ORDAH]

svy, subpop(if ORDA1 == 1): prop   INTELAB2, level(83.4)
svy, subpop(if ORDB1 == 1): prop   INTELAB2, level(83.4)
svy, subpop(if ORDBA != .): prop   INTELAB2, over(ORDBA) level(83.4) coeflegend
lincom _b[1.INTELAB2@0bn.ORDBA] - _b[1.INTELAB2@1.ORDBA] 

svy, subpop(if ORDB1 == 1): prop   INTELBA2, level(83.4)
svy, subpop(if ORDA1 == 1): prop   INTELBA2, level(83.4)
svy, subpop(if ORDAB != .): prop   INTELBA2, over(ORDAB) level(83.4) coeflegend
lincom _b[1.INTELBA2@0bn.ORDAB] - _b[1.INTELBA2@1.ORDAB] 

svy, subpop(if ORDH1 == 1): prop   INTELHW2, level(83.4)
svy, subpop(if ORDW1 == 1): prop   INTELHW2, level(83.4)
svy, subpop(if ORDWH != .): prop   INTELHW2, over(ORDWH) level(83.4) coeflegend
lincom _b[1.INTELHW2@0bn.ORDWH] - _b[1.INTELHW2@1.ORDWH] 

svy, subpop(if ORDW1 == 1): prop   INTELWH2, level(83.4)
svy, subpop(if ORDH1 == 1): prop   INTELWH2, level(83.4)
svy, subpop(if ORDHW != .): prop   INTELWH2, over(ORDHW) level(83.4) coeflegend
lincom _b[1.INTELWH2@0bn.ORDHW] - _b[1.INTELWH2@1.ORDHW]

svy, subpop(if ORDH1 == 1): prop   INTELHB2, level(83.4)
svy, subpop(if ORDB1 == 1): prop   INTELHB2, level(83.4)
svy, subpop(if ORDBH != .): prop   INTELHB2, over(ORDBH) level(83.4) coeflegend
lincom _b[1.INTELHB2@0bn.ORDBH] - _b[1.INTELHB2@1.ORDBH]

svy, subpop(if ORDB1 == 1): prop   INTELBH2, level(83.4)
svy, subpop(if ORDH1 == 1): prop   INTELBH2, level(83.4)
svy, subpop(if ORDHB != .): prop   INTELBH2, over(ORDHB) level(83.4) coeflegend
lincom _b[1.INTELBH2@0bn.ORDHB] - _b[1.INTELBH2@1.ORDHB]

svy, subpop(if ORDW1 == 1): prop   INTELWB2, level(83.4)
svy, subpop(if ORDB1 == 1): prop   INTELWB2, level(83.4)
svy, subpop(if ORDBW != .): prop   INTELWB2, over(ORDBW) level(83.4) coeflegend
lincom _b[1.INTELWB2@0bn.ORDBW] - _b[1.INTELWB2@1.ORDBW]

svy, subpop(if ORDB1 == 1): prop   INTELBW2, level(83.4)
svy, subpop(if ORDW1 == 1): prop   INTELBW2, level(83.4)
svy, subpop(if ORDWB != .): prop   INTELBW2, over(ORDWB) level(83.4) coeflegend
lincom _b[1.INTELBW2@0bn.ORDWB] - _b[1.INTELBW2@1.ORDWB]

**************************************************************************
* Randomization check [for the appendix]
**************************************************************************

gen     FIRST = 0
replace FIRST = 1 if ORDW1 == 1
replace FIRST = 2 if ORDB1 == 1
replace FIRST = 3 if ORDH1 == 1
replace FIRST = 4 if ORDA1 == 1
label define FIRST 1 "White" 2 "Black" 3 "Hispanic-American" 4 "Asian-American"
label values FIRST FIRST
tab     FIRST
tab     FIRST if weight != .

codebook gender
recode   gender (1=0) (2=1), gen(FEMALE)
tab      gender FEMALE, mi

codebook rwh
recode   rwh (1=1) (2=0), gen(RWHITE)
tab      rwh RWHITE, mi

codebook rbl
recode   rbl (1=1) (2=0), gen(RBLACK)
tab      rbl RBLACK, mi

codebook eth
recode   eth (1=1) (2=0), gen(RHISPN)
tab      eth RHISPN, mi

codebook ras
recode   ras (1=1) (2=0), gen(RASIAN)
tab      ras RASIAN, mi

tab      birthyr_dropdown
gen      AGE = 2022 - birthyr_dropdown
sum      AGE  

codebook educ
clonevar EDUC = educ
tab      educ EDUC, mi nol

codebook pid7
clonevar PID7 = pid7 if pid7 >=1 & pid7 <= 7
tab      pid7 PID7, mi

* Sample of participants who received a sampling weight

tab   FEMALE FIRST if weight != ., exact
tab   RWHITE FIRST if weight != ., exact
tab   RBLACK FIRST if weight != ., exact
tab   RHISPN FIRST if weight != ., exact
tab   RASIAN FIRST if weight != ., exact
anova AGE    FIRST if weight != .
anova EDUC   FIRST if weight != .
anova PID7   FIRST if weight != .

prop  FEMALE if weight != ., over(FIRST) level(83.4)
prop  RWHITE if weight != ., over(FIRST) level(83.4)
prop  RBLACK if weight != ., over(FIRST) level(83.4)
prop  RHISPN if weight != ., over(FIRST) level(83.4)
prop  RASIAN if weight != ., over(FIRST) level(83.4)
mean  AGE    if weight != ., over(FIRST) level(83.4)
mean  EDUC   if weight != ., over(FIRST) level(83.4)
mean  PID7   if weight != ., over(FIRST) level(83.4)

* Full sample

tab   FEMALE FIRST, exact
tab   RWHITE FIRST, exact
tab   RBLACK FIRST, exact
tab   RHISPN FIRST, exact
tab   RASIAN FIRST, exact
anova AGE    FIRST
anova EDUC   FIRST
anova PID7   FIRST

prop  FEMALE, over(FIRST) level(83.4)
prop  RWHITE, over(FIRST) level(83.4)
prop  RBLACK, over(FIRST) level(83.4)
prop  RHISPN, over(FIRST) level(83.4)
prop  RASIAN, over(FIRST) level(83.4)
mean  AGE   , over(FIRST) level(83.4)
mean  EDUC  , over(FIRST) level(83.4)
mean  PID7  , over(FIRST) level(83.4)
